// import { sendProxy } from 'h3';
export default defineEventHandler(event => {
    // 跨域处理
    if (!event.node.req.url?.startsWith('/proxy-api/')) {
        return;
    }

    // 代理转发
    const { apiUrl } = useRuntimeConfig().public;
    const url = event.node.req.url.replace(/^\/proxy-api/, '');

    const target = new URL(url, apiUrl);

    // 设置请求头
    return proxyRequest(event, target.toString(), {
        headers: {
            host: target.host, // if you need to bypass host security
        },
    });

    // return await sendProxy(event, target.toString());
});
